"""
======================
@Software:PyCharm
@author:LiMengJie
@time:2023/2/320:10
@File:线性规划1.py
 -*- coding: utf-8 -*-
======================
"""


# 标准形式为：
# min z=2 X1+3 X2+x3
# s.t
# x1+4x2+2x3>=8
# 3x1+2x2>=6
# x1,x2,x3>=0

import numpy as np
from scipy.optimize import linprog
#
# res=linprog(c,A,b,Aeq,beq)#默认每个决策变量下界为0，上界为正无穷。
# res=linprog(c,A=None,b=None,Aeq=None,beq=None,bounds=None,method='simplex')
# print(res.fun)#显示目标函数最小值
# print(res.x)#显示最优解


c = np.array([2, 3, 1])
A_up = np.array([[-1, -4, -2], [-3, -2, 0]])
b_up = np.array([-8, -6])

r = linprog(c, A_ub=A_up, b_ub=b_up, bounds=((0, None), (0, None), (0, None)))

print("目标函数的最小值：",r.fun)
print("最优解：",r.x)